#include<iostream>
#include<cstdio>
using namespace std;
int Sum(int n){
	int i=1,a,sum=0;
	do{
		a=i; 
		do{
		  sum+=a%10;
		  a=a/10;
		}while(a!=0); 
		i++;
	}while(i<=n); 
	return sum;
}
int main(){
	int n,sum;
	cin>>n;
	sum=Sum(n);
	cout<<sum;
	return 0;
}
